package com.fjec.common.okhttp;

import lombok.extern.slf4j.Slf4j;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

import java.io.IOException;

/**
 * 全局Http头拦截器
 */
@Slf4j
public class HeaderInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request orgRequest = chain.request();
        Request newRequest = orgRequest.newBuilder()
                .header("myheader", "myheadervalue")
                .build();
        return chain.proceed(newRequest);
    }
}
